package stbu;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import stbu.bean.User;

import java.util.Date;

@Controller
@RequestMapping("/user")
public class controller {

    @GetMapping("/toReg")
    public  String toReg() {

        return "reg";
    }
    @RequestMapping("/reg")
    public String reg(@RequestParam("username") String u1,
                      @RequestParam("pwd") String password, Model model){
        User user = new User();
        user.setUsername(u1);
        user.setPassword(password);
        Date regDate = new Date();
        model.addAttribute("regDate",regDate);
        model.addAttribute("user",user);
        return "forward:toLogin";
    }
    @RequestMapping("/toLogin")
    public String toLogin() {
        return "login";
    }
}
